// 拖拽节流

const div1 = document.getElementById("div1");

function throttle(fn, delay = 100) {
  let timer = null;

  return function () {
    if (timer) {
      return;
    }

    timer = setTimeout(() => {
      // 这个函数中的arguments 就是event
      fn.apply(this, arguments);

      timer = null;
    }, delay);
  };
}

div1.addEventListener(
  "drag",
  throttle(function (e) {
    console.log(e.offsetX, e.offsetY);
  }, 200)
);
